import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
import { getMovieListRequest } from '../../api/movieRequest'
export const getMovieList = createAsyncThunk('movie/getMovieList', async () => {
    const re = await getMovieListRequest()
    return re.data.data.list
})

const countSlice = createSlice({
    name: 'movie',
    initialState: {
        movieList: []
    },
    reducers: {
    },
    extraReducers: {
        [getMovieList.fulfilled](prev, { payload }) {
            console.log('请求成功');
            prev.movieList = payload
        },
        [getMovieList.rejected](prev, { payload }) {
            console.log('请求失败');
        },
        [getMovieList.pending](prev, { payload }) {
            console.log('请求进行中');
        },

    }
})

export default countSlice.reducer;

